<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="/misc/css/base.css"  />
<link rel="stylesheet" type="text/css" href="/misc/css/btnicon.css"  />
<link rel="stylesheet" type="text/css" href="/misc/css/reset_admin.css"  />
<link rel="stylesheet" type="text/css" href="/misc/css/adminmenu.css"  />
<link rel="stylesheet" type="text/css" href="/misc/css/newadmin.css"  />
<script type="text/javascript" src="/misc/vendors/jquery/jquery_1.2.6.js"></script>
<script type="text/javascript" src="/misc/vendors/o2js/o2js.js"></script>
<script type="text/javascript" src="/misc/vendors/o2js/o2js_build.js"></script>
<script type="text/javascript" >
var baseUrl = "<?=$themeUrl?>";
$().ready(function(){

});
var grids;
</script>
</head>
<body   style="background-color:#fcfcfc"> 

 

<style type="text/css">
a.modify_a{
position:absolute;
right:10px;
top:5px;
}
.statusout{
position:relative;
}
.statusdiv{
float:left;
margin:5px;
border:1px solid #EBEBEB;
padding:5px;
color:#CCCCCC;
}
.statusdiv_on{
color:#FF6633;
background:url(/misc/images/yes.gif) top 5px left 3px no-repeat #FFFFCC;
padding-left:23px;
}


.vegediv_fix{
border: 1px solid #B2D9F0;
color: #0082CB;
background-color:#E8F3FF;
float: left;
margin: 1px 3px;
padding: 3px;
text-decoration: none;
}

.vegediv_slt{
border: 1px solid #CCCCCC;
color: #999999;
float: left;
margin: 1px 3px;
padding: 3px;
text-decoration: none;
}
.vegediv_slt_on{

border: 1px solid #B2D9F0;
color: #0082CB;
background-color:#E8F3FF;
}





table.packettb{
border-collapse:collapse;
width:100%;
}
table.packettb td{
border:1px solid #E8E8E8;
}
table.packettb tbody td.title{
color:#FF6600;
font-size:18px;
font-weight:bold;
padding:10px;
text-align:center;
}
table.packettb tbody td.info{
color:#666666;
font-size:14px;
padding:10px;

}
table.packettb thead th{
padding:7px;
background:#E9F7DF;
color:#666666;
border:1px solid #E8E8E8;
text-align:center;
}

</style>

<div style="margin:5px;">
	<div class="blockdiv">
		<div class="titlediv">基本信息</div>
		
		<table class="mytable" style="width:97%" > 
			<tr>
				<td class="mylabel"> 配送分支标识：</td>
				<td class="myinfo" style="color:#FF3333" colspan="3" > 
					<input type="hidden" id="id" name="id" value="{$rs_sendfen.id}" /> 
					{$rs_sendfen.name}
				</td>
			</tr> 
			<tr>
				<td class="mylabel"> 配送会员数：</td>
				<td class="myinfo" > 
					{$rs_sendfen.users}
				</td>
				<td class="mylabel"> 包装种类数：</td>
				<td class="myinfo" > 
					{$rs_sendfen.packetnum}
				</td>
			</tr>	
			<tr>
				<td class="mylabel"> 创建人：</td>
				<td class="myinfo"   > 
					{$rs_sendfen.created_username} ({$rs_sendfen.created})
				</td>
				<td class="mylabel"> 最后修改人：</td>
				<td class="myinfo"   > 
					{$rs_sendfen.updated_username}({$rs_sendfen.updated})
				</td>
			</tr>
			<tr>
				<td class="mylabel"> 固定配送菜品：</td>
				<td class="myinfo" colspan="3" > 
					<?PHP
					foreach($rs_sendfen_vege as $v){
						if($v['fixed'] == '1'){
							echo '<div class="vegediv_fix">'.$v['name'].'('.$v['code'].') '.$v['vege_num'].' 份</div>';
						}
					}
					?> 
				</td> 
			</tr> 
			<tr>
				<td class="mylabel"> 可选配送菜品：</td>
				<td class="myinfo" colspan="3" >
					<?PHP
					foreach($rs_sendfen_vege as $v){
						if($v['fixed'] == '0'){
							echo '<div class="vegediv_slt '.($v['vege_num']>0?"vegediv_slt_on":"").'">'.$v['name'].'('.$v['code'].') '.$v['vege_num'].' 份</div>';
						}
					}
					?> 
				</td> 
			</tr>
			<tr>
				<td class="mylabel"> 自选菜品总份数：</td>
				<td class="myinfo" colspan="3" >
					{$rs_sendfen.sltnum}
				</td> 
			</tr> 
		</table> 
	</div>
</div>
<div style="margin:5px;">	
	<div class="blockdiv">
		<div class="titlediv">配送包装（共 {count($rs_packet)} 种）</div>
		<table class="packettb" style="width:97%" >
			<thead>
				<tr>
					<th style="width:30px;">
						序号
					</th>
					<th>
						包装菜品
					</th>
					<th style="width:80px;">
						配送会员数
					</th>
				</tr>
			</thead>
			<tbody>
			<?PHP
			foreach($rs_packet as $k=>$v){
				echo '
				<tr>
					<td class="title">'.($k+1).'</td>
					<td class="info">'.$v['veges_html'].'</td>
					<td class="info">
						 '.$v['usernum'].'名会员
					</td>
				</tr>
				';
			}
			?>
			</tbody>
		</table>
	</div>	
</div> 

<div style="margin:5px;">
	<div class="blockdiv">
		<div class="titlediv">配送会员</div>
	  
			<div style="margin:10px auto;">
				搜索：
				<select id="packettype" class="textBox" style="margin-right:40px;">
					<option value="">-- 所有配送包装 --</option>
				<?PHP
				foreach($packetindex as $k=>$v){
					echo '<option value="'.$k.'">第'.$v.'种配送包装</option>';
				}
				?>
				</select> 
				<span style="margin-left:0px;">
					<input type="text" maxlength="12" id="keywords" class="searchs" /> 
					<input type="button"  onclick="fnSearchs()" value="查询"  />  	
				</span>	
			</div>
			
		<div id="grids"></div> 
	</div>
</div>	


<script type="text/javascript">
var url_list = '/admin_sendfen/pi_modify_userlist';
var url_del = '/admin_sendfen/pi_modify_removeuser';
var url_add = '/admin_sendfen/pi_modify_adduser';

$().ready(function(){
	o2js.build('ymprompt');
	o2js.build('jquery_cluetip');
	o2js.build('o2grid');
	showLoading();
	grids = new o2Grid({
		bind:'grids', 
		url:url_list,
		pageNum:20,
		imgpath:'/misc/vendors/o2js/o2grid/image',
		cols:[
			{index:'id',mapping:'a.id', name:'序号', width:35,sortable:false, func:function(val,row_index,column_name,json,R){
				 return  '<span title="ID：'+json.id+'" >'+((R.page - 1)*R.rowNum + (row_index+1))+'</span>';
			}}, 
			{index:'classes',mapping:'c.val', name:'会员类型', width:70 
			},
			{index:'username',mapping:'b.username', name:'会员编号', width:70,func:function(val,row_index,column_name,json,R){
					return val;
				}
			},
			{index:'name',mapping:'b.name', name:'会员姓名', width:70 
			},
			{index:'veges_html',mapping:'a.packet', name:'配送菜品', width:600
			}
		],
		baseParams:{
			sendfen_id:{$rs_sendfen.id}
		}
	});
	fnSearchs();	 
	$('#keywords').keypress(function(e){
		if(e.keyCode==13||e.keyCode==10){
			fnSearchs();
		}
	});
});
function fnSearchs(){
	grids.setBaseParams({
		keywords:encodeURIComponent($('#keywords').val()),
		packettype:$('#packettype').val()
	}); 
	grids.load(1); 
}
function fnAddSendUser(){
	GfnSelectUser('onFnAddSendUser','增加配送会员');
}
function onFnAddSendUser(e){
	$.post(
		url_add,
		{
			ids:JSON.encode(e.user_ids),
			sendfen_id:{$rs_sendfen.id}
		},
		function(e){
			var ok = errorHandler(e);
			if(ok && ok.success=='1'){
				window.location.reload();
			}
		}
	);
}

/* 删除 */
function fnDelUser(NId){
	fnConfirm({
		str:'确认移除当前会员配送?',
		func_true:function(){
			$('button').attr('disabled','disabled');
			$.post(
				url_del,
				{
					id:NId
				},
				function(e){
					var ok = errorHandler(e);
					if(ok && ok.success=='1'){
						self.location.reload();
					}
					$('button').attr('disabled','');
				}
			);
		}
	}); 
}
</script>

</body>
</html>